package interceptor;

import entity.User;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CheckInter implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest req, HttpServletResponse resp, Object h) throws Exception {
        User u= (User) req.getSession().getAttribute("user");
        if(u==null){
            resp.sendRedirect("/inter/showLogin");
            return false;//流程中断
        }
        return true;//放行
    }
}
